<?PHP
/**
 * @copyright (C) Kapil Sharma; www.kapilsharma.info
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU version 3.
 * 
 * @author Kapil Sharma; www.kapilsharma.info
 * @version 0.1
 */
require_once 'conf.php';
class PGraph
{
    private $_width="300";
    private $_height="200";
    private $_config=array();
    private $_data=array();
    private static $_factory;
    private $_width="300";
    private $_height="200";
    /**
     * Constract PGraph Object with defined width and height and optional configurations
     * 
     * @param integer $width Required. Width of SVG
     * @param integer $height Required. Height of SVG
     * @param array $config Optional. Configurations
     */
    public function __construct($width,$height,$config=null)
    {
        $this->_width=$width;
        $this->_height=$height;
        if(is_array($config))
        {
            $this->_config=$config;
        }
    }

    /**
     *
     * @param 'numbers or single array' Required. Values in numbers.
     */
    public function setData()
    {
        $this->_data=(is_array($args[0])?$args[0]:$args);
    }

    /**
     * Draw the graph.
     * 
     * @param String $graph Required. Type of graph needed.
     */
    public function render($graph)
    {
        //ToDo Once graph factory start throwing exception, put it in try catch.
        if(!self::$_factory){
            require_once $config['OS_PATH']."graph".DIRECTORY_SEPARATOR."graphfactory.php";
            self::$_factory=GraphFactory::getInstance();
        }
        $graph=self::$_factory->getGraph($graph,$this->_height,$this->_width,$this->_config);
        $graph->render($this->_data);
    }
}
//EOF: pgraph.php